<!DOCTYPE html>
<html>
<head>
<title>添加管理员</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>添加管理员</h5>
            </div>
           <form id="inputForm" action="save" method="post">
	            <div class="ibox-content">
	                <div class="form-horizontal clearfix">
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">用户名：</label>
	                        <div class="col-sm-3">
	                            <input class="form-control" type="text" name="username">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">密码：</label>
	                        <div class="col-sm-3">
	                            <input id="password" class="form-control" type="password" name="password" autocomplete="off">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">确认密码：</label>
	                        <div class="col-sm-3">
	                            <input class="form-control" type="password" name="rePassword" autocomplete="off">
	                        </div>
	                    </div>
	                    <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="name">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>如：编辑</span>
                            </div>
                        </div>
	                    <div class="form-group">
                            <label class="col-sm-3 control-label">超级管理员：</label>
                            <div class="col-sm-3">
                                <div class="radio">
                                    <label class="m-r"><input name="type" value="1" type="radio">是</label>
                                    <label class="m-r"><input name="type" value="0" type="radio">否</label>
                                </div>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>超级管理员不受权限所控制</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">权限：</label>
                            <div class="col-sm-8">
                                <div class="form-group">
		                            <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">模型管理：</a></label>
		                            <div class="col-sm-6">
		                                 <div class="checkbox">
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/model" />模型管理
		                                    </label>
		                                </div>
		                            </div>
		                        </div>
		                        <div class="form-group">
		                            <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">栏目管理：</a></label>
		                            <div class="col-sm-6">
		                                 <div class="checkbox">
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/category" />栏目管理
		                                    </label>
		                                </div>
		                            </div>
		                        </div>
		                        <div class="form-group">
		                            <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">内容管理：</a></label>
		                            <div class="col-sm-6">
		                                 <div class="checkbox">
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/content" />内容管理
		                                    </label>
		                                </div>
		                            </div>
		                        </div>
		                        <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">表单管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/form" />表单管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">自定义表管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/table" />自定义表管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
		                        <div class="form-group">
		                            <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">营销管理：</a></label>
		                            <div class="col-sm-6">
		                                 <div class="checkbox">
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/ad" />广告
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/ad_position" />广告位
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/friend_link" />友情链接
		                                    </label>
		                                </div>
		                            </div>
		                        </div>
		                        <div class="form-group">
		                            <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">系统管理：</a></label>
		                            <div class="col-sm-6">
		                                 <div class="checkbox">
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/role" />角色
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/admin" />管理员
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/config" />系统配置
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/template" />模板
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/cache" />清除缓存
		                                    </label>
		                                    <label class="m-r">
		                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/profile" />账号设置
		                                    </label>
		                                </div>
		                            </div>
		                         </div>
                            </div>
                        </div>
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
	                <button type="submit" class="btn btn-w-m btn-primary">确定</button>
	                <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
	            </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
    var $selectAll = $("#inputForm .selectAll");
    
    
    
    $selectAll.click(function() {
        var $this = $(this);
        var $thisCheckbox = $this.closest("div").find("input:checkbox");
        if ($thisCheckbox.filter(":checked").size() > 0) {
            $thisCheckbox.prop("checked", false);
        } else {
            $thisCheckbox.prop("checked", true);
        }
        return false;
    });
    
	
	// 表单验证
	$inputForm.validate({
		rules: {
			username: {
				required: true,
				pattern: /^[0-9a-zA-Z_\u4e00-\u9fa5]+$/,
				minlength: 2,
				remote: {
					url: "checkUsername",
					cache: false
				}
			},
			password: {
				required: true,
				minlength: 4
			},
			rePassword: {
				required: true,
				equalTo: "#password"
			},
			type:"required"
		},
		messages: {
			username: {
				pattern: "非法字符",
				remote: "已存在"
			}
		}
	});

});
</script>